<style>
    #container{
        position: fixed;
        height: 100%;
        width: 100%;
    }
    #tip {
        position: fixed;
        background-color: #fff;
        border: 1px solid #ccc;
        border-radius: 3px;
        height: 35px;
        padding: 0 5px;
        line-height: 35px;
        left: 55px;
        bottom: 20px;
        display: none;
    }
    .footer.footer-home {display: none;}
</style>
<?php if($_GET['type']!='app'): ?>
<div class="header">
    <a href="javascript:history.go(-1); " class="return iconfont icon-shangyiye"></a>
    <div class="header-title">地图</div>
</div>
<?php endif; ?>
<div id="container" tabindex="0"></div>
<div id="tip"></div>
<script type="text/javascript" src="//webapi.amap.com/maps?v=1.3&key=5c7baac99d10897f7b2afa1aec0622e3"></script>
<script type="text/javascript" src="//cache.amap.com/lbs/static/addToolbar.js"></script>
<script type="text/javascript">
    var map = new AMap.Map('container',{
        resizeEnable: true,
        zoom: 10
    });

    map.plugin('AMap.Geolocation', function() {
        var geolocation = new AMap.Geolocation({
            enableHighAccuracy: true,
            timeout: 10000,
            buttonOffset: new AMap.Pixel(10, 20),
            zoomToAccuracy: true,
            buttonPosition:'LB'
        });
        map.addControl(geolocation);
        geolocation.getCurrentPosition();
        AMap.event.addListener(geolocation, 'complete', onComplete);
        AMap.event.addListener(geolocation, 'error', onError);
    });
    //解析定位结果
    function onComplete(data) {
        AMap.service('AMap.Driving',function(){//回调函数
            var driving = new AMap.Driving({
                map: map,
                //panel: "result"
            });
            driving.search([
                {keyword: data.formattedAddress},
                {keyword: '<?php echo $_GET['addr']; ?>'}
            ]);
        })
    }
    //解析定位错误信息
    function onError(data) {
        var tip = document.getElementById('tip');
        tip.style.display = 'block';
        tip.innerHTML = '定位失败';
    }
</script>













